home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 October: Mac OS SDK / Dev.CD Oct 96 SDK / Dev.CD Oct 96 SDK2.toast / Development Kits (Disc 2) / OpenDoc / OpenDoc Development / Debugging Support / OpenDoc Source Code / Utilities / Interfaces / Node.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-22  |  2.6 KB  |  112 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        Node.h
  3.  
  4.     Contains:    Tree node class
  5.  
  6.     Owned by:    Richard Rodseth
  7.  
  8.     Copyright:    © 1993 - 1995 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     
  11.     In Progress:
  12. */
  13.  
  14. #ifndef _NODE_
  15. #define _NODE_
  16.  
  17. #ifndef _ODTYPES_
  18. #include "ODTypes.h"
  19. #endif
  20.  
  21. #ifndef _LINKLIST_
  22. #include "LinkList.h"
  23. #endif
  24.  
  25. //=====================================================================================
  26. // Classes defined in this interface
  27. //=====================================================================================
  28.  
  29. class Node;
  30. class NodeTraverser;
  31.  
  32. //=====================================================================================
  33. // Classes used by this interface
  34. //=====================================================================================
  35.  
  36. class Link;
  37. class LinkedList;
  38.  
  39. //=====================================================================================
  40. // Class Node
  41. //=====================================================================================
  42.  
  43. class  Node : private Link, private LinkedList
  44. {
  45.     public:
  46.         Node();
  47.         ~Node();
  48.  
  49.         ODULong Size();
  50.         
  51.         Node* GetParent();
  52.         Node* GetFirstChild();
  53.         Node* GetLastChild();
  54.         Node* GetNextSibling();
  55.         Node* GetPreviousSibling();
  56.             
  57.         void SetParent(Node* parent);
  58.         
  59.         void AddChildFirst(Node* node);
  60.         void AddChildLast(Node* node);
  61.         void AddChildBefore(Node& existing, Node* node);
  62.         void AddChildAfter(Node& existing, Node* node);
  63.         void RemoveChild(Node& node);
  64.         Node* GetChildAfter(Node* node);
  65.         Node* GetChildBefore(Node* node);
  66.  
  67.         Node* FirstTopDown();
  68.         Node* NextTopDown(ODSiblingOrder siblingOrder);
  69.         Node* GetNextAunt(ODSiblingOrder siblingOrder);
  70.         
  71.         Node* FirstBottomUp(ODSiblingOrder siblingOrder);
  72.         Node* NextBottomUp(ODSiblingOrder siblingOrder);
  73.  
  74.     private:
  75.         Node*        fParent;
  76. };
  77.  
  78. //=====================================================================================
  79. // Class NodeTraverser
  80. //=====================================================================================
  81.  
  82.  
  83. class NodeTraverser 
  84. {
  85. public:
  86.  
  87.     NodeTraverser(Node* root, 
  88.                   ODTraversalType traversalType, 
  89.                   ODSiblingOrder siblingOrder);
  90.     ~NodeTraverser();
  91.  
  92.     Node*                First();
  93.     Node*                Next();
  94.     void                SkipChildren();
  95.     ODBoolean            IsNotComplete();
  96.  
  97. protected:    
  98.  
  99.     Node* FirstTopDown(Node* node);
  100.     Node* NextTopDown(Node* node, ODSiblingOrder siblingOrder);
  101.     Node* GetNextAunt(Node* node, ODSiblingOrder siblingOrder);
  102.     Node* FirstBottomUp(Node* node, ODSiblingOrder siblingOrder);
  103.     Node* NextBottomUp(Node* node, ODSiblingOrder siblingOrder);
  104.     
  105. private:
  106.       Node*             fRoot;
  107.      Node*             fCurrent;
  108.      ODTraversalType fTraversalType;
  109.      ODSiblingOrder  fSiblingOrder;
  110. };
  111.  
  112. #endif // _NODE_